//
//  KunGuideVC.swift
//  XK_
//
//  Created by Li Dong on 2022/12/16.
//

import UIKit

class KunGuideVC: KunBaseVC, UIScrollViewDelegate {
    
    @IBOutlet weak var scrollVIew: UIScrollView!
    private var pageIndex = 0
    @IBOutlet weak var textImgView_height1: NSLayoutConstraint!
    @IBOutlet weak var textImgView_height2: NSLayoutConstraint!
    @IBOutlet weak var textImgView_height3: NSLayoutConstraint!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        scrollVIew.delegate = self
//        textImgView_height1.constant = AppConfig.isEnglishEnv ? 68 : 44
//        textImgView_height2.constant = AppConfig.isEnglishEnv ? 68 : 44
//        textImgView_height3.constant = AppConfig.isEnglishEnv ? 68 : 44
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        pageIndex = Int(scrollView.contentOffset.x/CGFloat.screenWidth)
    }

    @IBAction func nextPage(_ sender: UIButton) {
        if pageIndex == 2 {
            let mainVC = KunBaseNavVC(rootViewController: KunHomeVC())
            UIApplication.shared.windows.first?.rootViewController = mainVC
            AppConfig.finishGuide = true
//            if !AppProducts.shared.isPurchased {
//                mainVC.showSubVC()
//            }
            return
        }
        pageIndex += 1
        scrollVIew.setContentOffset(CGPoint(x: pageIndex*Int(CGFloat.screenWidth), y: 0), animated: true)
    }
    

}
